//
//  GDMStatuesCellBottomView.swift
//  SinaWeibo
//
//  Created by mac on 15/12/1.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit

import SnapKit

class GDMStatuesCellBottomView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
//        backgroundColor = UIColor.orangeColor()
        addBtn()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func addBtn() {

      
        
        addSubview(oneBtn)
        
        addSubview(twoBtn)
        
        addSubview(threeBtn)
        
        
        //        获取view
        let setViewOne = setView()
        
        
        addSubview(setViewOne)
        
        let setViewTwo = setView()
        
        //        定义view的宽度
        let w : CGFloat = 0.5
        
        let scale = 0.4
        
       
        
        addSubview(setViewTwo)
        
        setViewOne.snp_makeConstraints { (make) -> Void in
            
            make.left.equalTo(oneBtn.snp_right)
            make.width.equalTo(w)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
        }
        
        setViewTwo.snp_makeConstraints { (make) -> Void in
            
            make.left.equalTo(twoBtn.snp_right)
            make.width.equalTo(w)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
        }
        
        threeBtn.snp_makeConstraints { (make) -> Void in

        make.left.equalTo(twoBtn.snp_right)
//            添加右边的约束就可以使用等宽等高了
        make.top.bottom.right.equalTo(self)
            make.width.equalTo(twoBtn.snp_width)
        }
        
        twoBtn.snp_makeConstraints { (make) -> Void in
            
            make.left.equalTo(oneBtn.snp_right)
            make.top.bottom.equalTo(self)
//            等宽
            make.width.equalTo(oneBtn.snp_width)
            
        }
        
        oneBtn.snp_makeConstraints { (make) -> Void in
            
            make.left.top.bottom.equalTo(self)
          
        }
        
//    MARK : 添加按钮的点击事件
oneBtn.addTarget(self, action: "oneBtnClick", forControlEvents: .TouchUpInside)
    
    }

    @objc private func oneBtnClick(){
        
//        点击按钮的时候跳转控制器
        let tempVC = GDMTempController()
        
        oneBtn.navController()?.pushViewController(tempVC, animated: true)
        
    }
    
    private lazy var oneBtn : UIButton = UIButton(title: "转发", backName: nil, color: UIColor.darkGrayColor(), fontSize: 14, isHightLight: true, imageName: "timeline_icon_retweet")
    private lazy var twoBtn : UIButton = UIButton(title: "评论", backName: nil, color: UIColor.darkGrayColor(), fontSize: 14, isHightLight: true, imageName: "timeline_icon_comment")
    private lazy var threeBtn : UIButton = UIButton(title: "点赞", backName: nil, color: UIColor.darkGrayColor(), fontSize: 14, isHightLight: true, imageName: "timeline_icon_unlike")
//    懒加载下面视图每一个按钮之间的线
    private func setView() -> UIView {
        
        let v = UIView()
        
        v.backgroundColor = UIColor.lightGrayColor()
        
        return v
        
    }
}
